#include "Explosao.h"

Explosao::Explosao(MODEL *model):posX(model->posX),posY(model->posY),f(model->f),
                                beta(model->beta),rho(model->rho),n(model->n),c(model->c),W(model->W)
{
    Tempo=&model->Time;
    Wp03=pow(W,0.3333);
    fbrn=-f * beta * rho * n;
    fbrc= f * beta * rho * c;
}
void Explosao::calcular(SPHERE *s)
{
    REAL R;   // distancia da particula a origem (onde esta a carga)
	REAL forcaP; // forca devido a pressao
	REAL Pos[2];
    REAL t;  // tempo
    t = *Tempo;
    Pos[0]=posX-s->R[0];
    Pos[1]=posY-s->R[1];
	R=NORM(Pos);
	Pos[0]/=R;
	Pos[1]/=R;
    forcaP = ((fbrn*pow(R/Wp03,-n)*exp(-t/R*c))/R+fbrc*pow(R/Wp03,-n)*t*exp(-t/R*c)/(R*R))*CONST_PI*s->Rad*s->Rad;
    s-> Force( forcaP, Pos );
}
